<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/layui/css/layui.css" rel="stylesheet" />
    <link href="/css/login.css" rel="stylesheet" />
</head>
<body>
    <!--整个页面中的最外层-->
    <div id="app">
        <div class="form-parent-div">
            <br>
            <br>
            <img src="../img/login-title.png" width="90%"/>
            <br>
            <br>
            <br>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="text" name="account" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <br>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="text" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <br>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="/layui/layui.js"></script>
    <script>
        layui.use(['form'], function(){
            var form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function(data){
                //layer.msg(JSON.stringify(data.field));
                $.ajax({
                    url:'http://localhost:8090/auth/login',
                    type:'post',
                    data:data.field,
                    success:function (param){
                        if (param.code == 200) {
                            alert(param.msg);
                            window.location.href = "login.html";
                        } else {
                            window.location.href="index.html";
                        }
                    }
                })
                return false;
            });
        });
    </script>
</body>
</html>
